#include <bits/stdc++.h>
using namespace std;
const int N = 1.9e4 + 7;

vector<int> ans;

int a[N];

int n, x;

inline void update(int l) {
    rotate(a + l, a + l + 1, a + l + x), ans.emplace_back(l);
}

signed main() {
    freopen("rotate.in", "r", stdin);
    freopen("rotate.out", "w", stdout);
    scanf("%d", &n);

    for (int i = 1; i <= n; ++i)
        scanf("%d", a + i);
    
    pair<long long, int> res = make_pair((long long)1e18, -1);
    
    for (int i = 2; i <= n; i += 2)
        res = min(res, make_pair(1ll * (i + n) * (n - i + 1) / i / 2 + 
            1ll * (n - i) * i + 1ll * (i - 2) * (i * 2 + 1), i));
    
    printf("%d ", x = res.second);

    for (int i = n; i >= x; --i) {
        int u = find(a + 1, a + n + 1, i) - a;

        for (; u + (x - 1) <= i; u += x - 1)
            update(u);

        if (u != i) {
            for (; u >= i - x + 1; --u)
                update(i - x + 1);
        }
    }

    for (int i = 1; i < x; ++i) {
        int p = find(a + 1, a + x, i) - a;

        if (p != i) {
            for (int j = 1; j <= p - i - 1; ++j)
                update(i + 1);

            update(i + 1);

            for (int j = 1; j <= x; ++j)
                update(i + (j & 1));

            for (int j = 1; j <= x - (p - i - 1); ++j)
                update(i + 1);
        }
    }

    printf("%d\n", (int)ans.size());

    for (int it : ans)
        printf("1 %d\n", it);
    
    return 0;
}
